<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script>
			//初始化
			function creatXMLHttpRequest(){
				var xmlhttprequest;
				if (window.ActiveXObject) {
					try{
						xmlhttprequest = new ActiveXObject("Msxml2.XMLHTTP");
					}catch(e){
						xmlhttprequest = new ActiveXObject("Microsoft.XMLHTTP");
					}
				} else{
					xmlhttprequest = new XMLHttpRequest();
				}
				return xmlhttprequest;
			}
			
			function fun(){
				//1.初始化
				xhr = creatXMLHttpRequest();
				//2.创建请求
				xhr.open("get","info.txt",false);
				//3.发送请求
				xhr.send();
				//4.处理数据
				var str = xhr.responseText;
				document.getElementById("text").innerHTML = str;
			}			
		</script>
	</head>
	<body>
		服务器传回来的数据是：<span id="text"></span>
		<br />
		<button onclick="fun()">请求数据</button>
	</body>
</html>
